package com.sky.client;

import com.sky.entity.Orders;
import com.sky.dto.GoodsSalesDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@FeignClient(name = "sky-service-order")
public interface OrderMapperClient {
    
    /**
     * 根据状态和下单时间查询订单
     * @param status
     * @param time
     * @return
     */
    @GetMapping("/order/getByStatusAndOrdertimeLT")
    List<Orders> getByStatusAndOrdertimeLT(@RequestParam Integer status, @RequestParam LocalDateTime time);
    
    /**
     * 更新订单信息
     * @param orders
     */
    @PutMapping("/order/update")
    void update(@RequestBody Orders orders);
    
    /**
     * 根据状态和时间范围统计订单数量
     * @param map
     * @return
     */
    @PostMapping("/order/countByMap")
    Integer countByMap(@RequestBody Map map);
    
    /**
     * 根据时间范围查询营业额
     * @param map
     * @return
     */
    @PostMapping("/order/sumByMap")
    Double sumByMap(@RequestBody Map map);
    
    /**
     * 查询商品销量排名
     * @param beginTime
     * @param endTime
     * @return
     */
    @GetMapping("/order/getSalesTop10")
    List<GoodsSalesDTO> getSalesTop10(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime beginTime, 
                                      @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime);
}